<?php
// +----------------------------------------------------------------------
// | Author: fulei  Email:365581323@qq.com
// +----------------------------------------------------------------------
namespace app\back\controller;
use think\Controller;
use think\Request;
use think\Db;
use app\admin\model\User;
/*领队管理*/
class Captain extends Common
{   
    public function index()
    {   
       
        $captainList=Db::name('user_info')->where(['member_type'=>'2'])->paginate(3,false);
         $page = $captainList->render();
        $this->assign('captain',$captainList);
        $this->assign('page',$page);
        return $this->fetch('Captain/index');
    }
    
    //
    //删除领队
     public function del_captain()
    {
        $id = input('id');
       // print_r($id);die;
      $data = Db::name('captain_info')->where('id',$id)->find();
     // print_r($data);die;
        $captainPhoto = substr($data['captainPhoto'],33);
        $Img1 = substr($data['img1'],33);
        $Img2 = substr($data['img2'],33);
        $Img3 = substr($data['img3'],33);
        $Img4 = substr($data['img4'],33);
        $Img5 = substr($data['img5'],33);
        if(!empty($captain_info)){
          $rs=$this->uploadDel($captainPhoto);
        }
         if(!empty($Img1)){
            $rs=$this->uploadDel($Img1);
        }
         if(!empty($Img2)){
            $rs=$this->uploadDel($Img2);
        }
         if(!empty($Img3)){
            $rs=$this->uploadDel($Img3);
        }
         if(!empty($Img4)){
            $rs=$this->uploadDel($Img4);
        }
         if(!empty($Img5)){
            $rs=$this->uploadDel($Img5);
        }
        
    
        $list = Db::name('captain_info')->where("id",$id)->delete();
        if($list){
             return json(['state' => '1', 'msg' => '删除成功!']);
        }else{
            return json(['state' => '0', 'msg' => '删除失败再试试!']);
        }
        
    }
    
}